<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>轮播图更换</title>
<#assign base=request.contextPath  />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${base}/frame/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${base}/css/demo.css" type="text/css">
    <script src="${base}/js/jquery.min.js"></script>
    <script type="text/javascript" src="${base}/js/zhang.js"></script>
    <style type="text/css">
        form {
            padding: 20px;
        }

        .layui-btn-radius {
            border-radius: 5px;
        }
    </style>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>轮播图更换</legend>
</fieldset>
<button style="margin-left: 50px" type="button" class="layui-btn layui-btn-normal" id="test1">

        <i class="layui-icon">&#xe67c;</i>上传新的图片
</button>
<blockquote class="layui-elem-quote">
    当前显示图片：
          <#list images as list>
           <blockquote class="layui-elem-quote layui-quote-nm">
               <img     src="${base}/ppImage/getPhoto?path=${list.ppImageUrl}"  >
               <button  	class="layui-btn layui-btn-danger" onclick="delImage('${list.id}','${list.ppImageUrl}')">删除</button>
           </blockquote>
          </#list>

</blockquote>

<script src="${base}/frame/layui/layui.js"></script>
<script>
    layui.use('upload', function(){
        var upload = layui.upload;

        //执行实例
        var uploadInst = upload.render({
            elem: '#test1' //绑定元素
            ,url: '${base}/ppImage/upload' //上传接口
            ,done: function(res){
                //上传完毕回调
                alert("上传成功")
                location.reload();
            }
            ,error: function(){
                //请求异常回调
                alert("上传失败")
            }
        });
    });


    function delImage(id,url){
        $.ajax({
            type: "get",
            url:  "${base}/ppImage/delImage",
            async:false,
            data: {
                 id:id,
                ppImageUrl:url
            },
            success: function(data) {
                    if(data===true){
                        location.reload();
                    }else{
                        alert("上传失败")
                    }
            }
        });
    }
</script>
</body>
</html>